﻿<UserControl x:Class="WpfApp.UserControls.Employees"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             xmlns:dx="http://schemas.devexpress.com/winfx/2008/xaml/core"
             dx:ThemeManager.ThemeName="Office2007Blue"
             xmlns:dataprovider="clr-namespace:WpfApp.DataProvider"
             mc:Ignorable="d" 
             d:DesignHeight="300" d:DesignWidth="300" xmlns:dxg="http://schemas.devexpress.com/winfx/2008/xaml/grid" xmlns:dxe="http://schemas.devexpress.com/winfx/2008/xaml/editors">
    <UserControl.Resources>
        <!-- Создаем экземпляр нашего класса DataProvider -->
        <ObjectDataProvider x:Key="EmployeesDataProvider" ObjectType="{x:Type dataprovider:EmployeesDataProvider}"/>
        <!-- определяем метод который вызывается для получения данных о сотрудниках -->
        <ObjectDataProvider x:Key="Employees" ObjectInstance="{StaticResource EmployeesDataProvider}" MethodName="GetEmployees"/>
    </UserControl.Resources>
    <Grid DataContext="{Binding Source={StaticResource Employees}}">
        
        <Grid.RowDefinitions>
            <RowDefinition Height="*"></RowDefinition>
            <RowDefinition Height="Auto"></RowDefinition>
        </Grid.RowDefinitions>

        <dxg:GridControl ItemsSource="{Binding}" x:Name="gridEmployees" AutoPopulateColumns="True" ShowBorder="False" Grid.Row="0">
                
                <dxg:GridControl.Columns>
                    <dxg:GridColumn FieldName="ID_Employee" Visible="False" Header="ID" AllowEditing="False" />
                    <dxg:GridColumn FieldName="Title" Header="Должность" AllowEditing="True" />
                    <dxg:GridColumn FieldName="Name" Header="Ф.И.О." AllowEditing="True" />
                </dxg:GridControl.Columns>
            
                <dxg:GridControl.View>
                    <dxg:TableView x:Name="tableEmployees" ShowAutoFilterRow="True" ShowTotalSummary="False" BestFitMode="VisibleRows" AllowBestFit="True" BestFitArea="Rows" AutoWidth="True" VerticalScrollbarVisibility="Auto" NavigationStyle="Cell" NewItemRowPosition="Top" />
                </dxg:GridControl.View>
            
        </dxg:GridControl>

        <Button Content="Сохранить" Grid.Row="1" HorizontalAlignment="Left" Margin="10,10,10,10" Name="buttonSave" Width="100" Height="23" VerticalAlignment="Top" Click="buttonSave_Click" />
        <!--<Button Content="Закрыть" Grid.Row="1" HorizontalAlignment="Left" Margin="120,10,10,10" Name="buttonClose" Width="100" Height="23" VerticalAlignment="Top" />-->

    </Grid>    
</UserControl>
